<?php
include("../config.php");
include("../inc/func.php");
include("../db.php");
$debug = TRUE;
loginCheck();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php site_title();?> Control Panel - Manage</title>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="../inc/js/thickbox.css" type="text/css" media="screen" />
<script type="text/javascript" src="../inc/js/jquery.js"></script>
<script type="text/javascript" src="../inc/js/thickbox.js"></script>
</head>
<body>
<div id="wrap">
  <div id="head">
    <div id="title"><?php site_title(); ?><div class="gotosite"> <a href="../">Go to your site &raquo;</a></div></div>
  </div>
  <div id="nav">
    <ul>
      <li><a href="index.php">Main</a></li>
      <li><a href="post.php">Post</a></li>
      <li class="current"><a href="manage.php">Manage</a></li>
      <li><a href="theme.php">Themes</a></li>
      <li><a href="options.php">Options</a></li>
    </ul>
  </div>  
  <div id="content">
  <?php
  if($_GET['edited']) {
	  echo "<div id=\"success\">Edited successfully</div>";
  }
  ?>
<table id="table" cellspacing="0">
<thead>
<tr>
	<th style="width:10px;">ID</th>
	<th style="width:270px;">Title</th>
	<th style="width:100px;">Author</th>
	<th style="width:25px;">Type</th>
	<th style="width:25px;">Date</th>
	<th style="width:15px;">&nbsp;</th>
	<th style="width:15px;">&nbsp;</th>
</tr>
</thead>
<tbody id="tbody">
<?php
  global $db_prefix;
  $count = 0;
  $postquery  = "SELECT * FROM $db_prefix"."posts ORDER BY id DESC";
  $postresult = mysql_query($postquery);
  if(mysql_num_rows($postresult) == 0) {echo("No posts!");}
  else { 
	  while($postrow = mysql_fetch_row($postresult)) {
	  $id = $postrow[0];
	  $title = $postrow[1];
	  $author = $postrow[2];
	  $date = $postrow[3];
	  $type = $postrow[4];
	  $text = strip_tags($postrow[5]);
	  $text = substr($text,0,55);
	  if(checkNum($count) === TRUE) {$row = "odd";}
	  else {$row = "even";}
	  if(empty($title)) {$title = $text;}
	  echo "<tr class=\"$row\">
			<td class=\"id\">$id</td>
			<td class=\"title\">$title</td>
			<td>$author</td>
			<td class=\"type\">$type</td>
			<td>$date</td>
			<td><a href=\"../index.php?id=$id&TB_iframe=true&height=400&width=700\" class=\"thickbox\" title=\"$title\">Preview</a></td>
			<td><a href=\"edit.php?id=$id&type=$type\">Edit</a></td>
		</tr>";
		$count++;
	  }
  }
  ?>
</tbody>
</table>
  </div>
  <div id="footer"><?php LIversion(); ?></div>
</div>
</body>
</html>
